#已有同id箭矢转而增加次数
$execute store result score #IDisin temp run function dab:system/arrow_bundle/storage/add_arrow/isin_test {id:$(id)}
$execute if score #IDisin temp matches 1 run return run function dab:system/arrow_bundle/storage/add_arrow/add_count {id:$(id)}

summon armor_stand ~ ~ ~ {Tags:[tempEntity],Invisible:true,Small:true,Marker:true,Invulnerable:true}

item replace entity @n[tag=tempEntity,distance=..1,type=armor_stand] weapon.mainhand from entity @s hotbar.8

#data
data modify entity @n[tag=tempEntity,distance=..1,type=armor_stand] HandItems[0].components."minecraft:custom_data".bag append value {}
$data modify entity @n[tag=tempEntity,distance=..1,type=armor_stand] HandItems[0].components."minecraft:custom_data".bag[-1] merge from storage dab:system gameContents.arrow[{id:"$(id)"}]
data remove entity @n[tag=tempEntity,distance=..1,type=armor_stand] HandItems[0].components."minecraft:custom_data".bag[-1].cache_components
data modify entity @n[tag=tempEntity,distance=..1,type=armor_stand] HandItems[0].components."minecraft:custom_data".bag[-1].count set from storage dab:system temp.arrow_item.count

#如果在完成替换前是空袋子则执行命令块: "empty"
execute if function dab:system/arrow_bundle/storage/is_empty run tag @s add is_empty

item replace entity @s hotbar.8 from entity @n[tag=tempEntity,distance=..1,type=armor_stand] weapon.mainhand

#empty:{
execute as @s[tag=is_empty] run function dab:system/arrow_bundle/storage/no_empty
execute as @s[tag=is_empty] run function dab:system/arrow_bundle/storage/set_select_arrow {value:0}
#}

tag @s[tag=is_empty] remove is_empty
kill @n[type=armor_stand,distance=..1,tag=tempEntity]
data remove storage dab:system temp.arrow_item

playsound item.bundle.insert player @a ~ ~ ~ 1.0 1.0

#update
function dab:system/arrow_bundle/storage/update